package org.jeecg.modules.test;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.online.cgform.enhance.CgformEnhanceJavaInter;
import org.jeecg.modules.online.cgform.mapper.OnlCgformFieldMapper;
import org.jeecg.modules.online.config.exception.BusinessException;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class demo implements CgformEnhanceJavaInter {
    @Override
    public void execute(String s, Map<String, Object> map) throws BusinessException {

    }

    @Override
    public void execute(String tableName, JSONObject jsonObject) throws BusinessException {
        System.out.println("---------进入java增强方法---begin");
        System.out.println("表名"+tableName);
        System.out.println("json"+jsonObject.toString());
        OnlCgformFieldMapper onlCgformFieldMapper= SpringContextUtils.getBean(OnlCgformFieldMapper.class);
        Map<String,Object> params=new HashMap<>();
        //使用mybatis的语法
        String sql="update "+tableName+" set edu_date = #{eduDate,jdbcType=DATE} where id = #{id,jdbcType=VARCHAR}";
        params.put("execute_sql_string",sql);
        params.put("eduDate",new Date());
        params.put("id",jsonObject.getString("id"));
        onlCgformFieldMapper.executeUpdatetSQL(params);
        System.out.println("---------进入java增强方法---end");
    }
}
